package com.ruoyi.basicData.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basicData.domain.RareaManagement;
import com.ruoyi.basicData.service.IRareaManagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库位管理Controller
 * 
 * @author admin
 * @date 2024-06-26
 */
@RestController
@RequestMapping("/basicData/rareaManagement")
public class RareaManagementController extends BaseController
{
    @Autowired
    private IRareaManagementService rareaManagementService;

    /**
     * 查询库位管理列表
     */
    @PreAuthorize("@ss.hasPermi('basicData:rareaManagement:list')")
    @GetMapping("/list")
    public TableDataInfo list(RareaManagement rareaManagement)
    {
        startPage();
        List<RareaManagement> list = rareaManagementService.selectRareaManagementList(rareaManagement);
        return getDataTable(list);
    }

    /**
     * 导出库位管理列表
     */
    @PreAuthorize("@ss.hasPermi('basicData:rareaManagement:export')")
    @Log(title = "库位管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RareaManagement rareaManagement)
    {
        List<RareaManagement> list = rareaManagementService.selectRareaManagementList(rareaManagement);
        ExcelUtil<RareaManagement> util = new ExcelUtil<RareaManagement>(RareaManagement.class);
        util.exportExcel(response, list, "库位管理数据");
    }

    /**
     * 获取库位管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('basicData:rareaManagement:query')")
    @GetMapping(value = "/{rareaManagementId}")
    public AjaxResult getInfo(@PathVariable("rareaManagementId") Long rareaManagementId)
    {
        return success(rareaManagementService.selectRareaManagementByRareaManagementId(rareaManagementId));
    }

    /**
     * 新增库位管理
     */
    @PreAuthorize("@ss.hasPermi('basicData:rareaManagement:add')")
    @Log(title = "库位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RareaManagement rareaManagement)
    {
        return toAjax(rareaManagementService.insertRareaManagement(rareaManagement));
    }

    /**
     * 修改库位管理
     */
    @PreAuthorize("@ss.hasPermi('basicData:rareaManagement:edit')")
    @Log(title = "库位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RareaManagement rareaManagement)
    {
        return toAjax(rareaManagementService.updateRareaManagement(rareaManagement));
    }

    /**
     * 删除库位管理
     */
    @PreAuthorize("@ss.hasPermi('basicData:rareaManagement:remove')")
    @Log(title = "库位管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rareaManagementIds}")
    public AjaxResult remove(@PathVariable Long[] rareaManagementIds)
    {
        return toAjax(rareaManagementService.deleteRareaManagementByRareaManagementIds(rareaManagementIds));
    }
}
